module.exports = function ($scope, $modalInstance, $resource, $modal, item, flag, toaster){
    

   


    init();
    function init(){
        $scope.url =  flag ?  '/api/as/ic/createcity/insertType' : '/api/as/ic/createcity/updateType'; 

        console.log(item)
        $scope.rulesinfo = flag ? {'flag': true} : angular.copy(item);
 
    }
    //保存
    $scope.save = function (){
       
        $resource( $scope.url , {}, {}).save($scope.rulesinfo, function(res){
            if(res.errcode === 0){
                toaster.success({title: '', body: '保存成功'});
                $modalInstance.close();
            }else{
                toaster.error({title: '', body: res.errmsg});
            }
        });
    }
   
    //取消
    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
    }


   
};